﻿using Cxuu.Models;
using Cxuu.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Cxuu.Web.Admin
{
    [Area("Admin")]
    [Authorize]
    public class HomeController : Base
    {
        private readonly NoticeKeyService _noticeKey;
        public HomeController(NoticeKeyService noticeKeyService)
        {
            _noticeKey = noticeKeyService;
        }

        public async Task<IActionResult> Index()
        {
            ViewAdminUser adminUser = await UserClaims();
            int noticeNum = await _noticeKey.CountAsync(adminUser.Id);
            ViewBag.noticeNum = noticeNum;
            ViewBag.userInfo = adminUser;
            return View();
        }

        public async Task<IActionResult> HomeAsync()
        {
            ViewBag.userInfo = await UserClaims();
            return View();
        }
    }
}
